import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

import { appRoutes } from "./routes";
import { REDIRECT_MAIN, NOT_FOUND_ROUTE } from "./routes/base";

const routes = [
  {
    path: "/",
    redirect: "/home/home",
  },
  {
    path: "/login",
    name: "login",
    component: () => import("@/views/login/index.vue"),
  },
  ...appRoutes,
  REDIRECT_MAIN,
  NOT_FOUND_ROUTE,
];

const router = new VueRouter({
  mode: "hash",
  base: process.env.BASE_URL,
  routes,
});

export function useRouter() {
  return router;
}

export function useRoute() {
  return router.currentRoute;
}

export default router;
